# 构建阶段
FROM maven:3.8.4-openjdk-17 as build-stage

WORKDIR /app

# 复制 pom.xml
COPY pom.xml .

# 复制源代码
COPY src ./src

# 构建应用
RUN mvn clean package -DskipTests

# 运行阶段
FROM openjdk:17-jdk-slim

WORKDIR /app

# 复制构建产物
COPY --from=build-stage /app/target/*.jar app.jar

# 暴露端口
EXPOSE 8080

# 设置时区
RUN apk add --no-cache tzdata && \
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone && \
    apk del tzdata

# 启动应用
ENTRYPOINT ["java", "-jar", "app.jar"] 